package com.hhit.bigscreenbackmanage.controller.jsgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.service.jsgl.TJsglStrwjdService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/jsgl/strwjd")
public class StrwjdController {

    private Logger log = LoggerFactory.getLogger(StrwjdController.class);

    @Autowired
    TJsglStrwjdService tJsglStrwjdService;

    /**
     * 查询 双碳任务进度明细
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getStrwjdList")
    public Response getStrwjdList(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Object> result = tJsglStrwjdService.queryStrwjdList(jsonObject);
            return Response.createResponseBySuccess("查询双碳任务进度明细成功",result);
        }catch (Exception e){
            log.error("查询双碳任务进度明细失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询双碳任务进度明细失败");
        }
    }

    /**
     * 查询 双碳重点任务统计
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getStzdrwCount")
    public Response getStzdrwCount(@RequestBody JSONObject jsonObject){
        try{
            Map<String, Integer> result = tJsglStrwjdService.queryStzdrwCount(jsonObject);
            return Response.createResponseBySuccess("查询双碳重点任务统计成功",result);
        }catch (Exception e){
            log.error("查询双碳重点任务统计失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询双碳重点任务统计失败");
        }
    }


    /**
     * 删除 双碳任务进度记录
     * @param jsonObject
     * @return
     */
    @RequestMapping("/deleteStzdrwRecord")
    public Response deleteStzdrwRecord(@RequestBody JSONObject jsonObject){
        try{
            tJsglStrwjdService.deleteStzdrwRecord(jsonObject);
            return Response.createResponseBySuccess("删除双碳任务进度记录成功");
        }catch (Exception e){
            e.printStackTrace();
            return Response.createResponseByError("删除双碳任务进度记录失败: "+e.getMessage());
        }
    }

}
